package com.gxa.weixing.pc.service.impl;

import com.gxa.weixing.core.common.ExceptionCode;
import com.gxa.weixing.core.exception.BusinessException;
import com.gxa.weixing.core.pojo.Manager;
import com.gxa.weixing.core.util.TimeToDate;
import com.gxa.weixing.pc.mapper.OrderManagerMapper;
import com.gxa.weixing.pc.service.OrderManagerService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * @author yang
 * @date 2022/1/7 9:11
 */
@Service
public class OrderManagerServiceImpl implements OrderManagerService {


    @Autowired(required = false)
    private OrderManagerMapper orderManagerMapper;

    @Override
    public List<Map<String, Object>> orderList(Map<String, Object> maps) throws Exception {
        System.out.println(maps);

        String logisticsType = maps.get("logisticsType").toString();
        String goodsName = maps.get("goodsName").toString();
        String supplierName = maps.get("supplierName").toString();
        String code = maps.get("code").toString();
        String time = maps.get("time").toString();
        String orderNo = maps.get("orderNo").toString();
        String take = maps.get("take").toString();
        String phone = maps.get("phone").toString();
        List<Map<String, Object>> mapList = orderManagerMapper.getOrderLIst(logisticsType, goodsName, supplierName, code, time, orderNo, take, phone);
        String name = "order_time";
        TimeToDate.time(mapList, name);
        return mapList;
    }

    @Override
    public List<Map<String, Object>> findById(String id) throws BusinessException, ParseException {
        if (StringUtils.isEmpty(id)) {
            throw new BusinessException(ExceptionCode.PARAM_ERROR);
        }

        List<Map<String, Object>> byId = orderManagerMapper.findById(id);
        String name = "order_time";
        TimeToDate.time(byId, name);
        return byId;
    }

    @Override
    public void addManager(Manager manager) throws Exception {

    }
}
